package com.gd.data.platform.flink.jobs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * Flink作业启动器
 * 在应用启动时自动启动Flink作业
 * 
 * @author gd-data-platform
 * @since 1.0.0
 */
@Slf4j
@Component
public class FlinkJobStarter implements CommandLineRunner {

    @Autowired
    private RealtimeMetricsJob realtimeMetricsJob;

    @Override
    public void run(String... args) throws Exception {
        log.info("启动Flink作业");

        try {
            // 启动实时指标计算作业
            realtimeMetricsJob.startJob();
        } catch (Exception e) {
            log.error("启动Flink作业失败", e);
        }
    }
}
